package com.pignest.hotel.module.user.ui;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Label;
import org.zkoss.zul.Row;
import org.zkoss.zul.Rows;

import com.pignest.hotel.beans.User;
import com.pignest.hotel.service.UserService;
import com.pignest.hotel.spring.Services;


public class UserGrid extends Grid implements EventListener {

	private static final Log LOG = LogFactory.getLog(UserGrid.class);
	
	private UserService userService;
	
	private String OrgId;
	
	public UserGrid(){
		userService=Services.getUserService();
		OrgId=null;
		refresh();
	}
	public void refresh(){
		List<User> users=userService.listAll(User.class);
		System.out.println(users.size());
		initUser(users);
	}
	public void initUser(List<User> user){
		System.out.println("****************************");
		List<Component> children = new ArrayList<Component>();

		Rows rows= new Rows();
		
		for(int i=0;i<user.size();i++){
			Row row = new Row();
			Label lab= new Label();
			lab.setValue("test");
			row.appendChild(lab);
			rows.appendChild(row);
		}
		
		children.add(rows);
	}
	@Override
	public void onEvent(Event arg0) throws Exception {
		// TODO Auto-generated method stub

	}
	

}
